package com.kuang.contrpller;

import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.thymeleaf.util.StringUtils;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {
    @RequestMapping("/user/login")
    public String login(String username, String password, Model model, HttpSession session){
        if (!StringUtils.isEmpty(username) && password.equals("123456")){
            session.setAttribute("userlogin",username);
            return "redirect:/main";
        }else {
            model.addAttribute("meg","用户或者密码错误！");
            return "index";
        }
    }
}
